from ui.Ui_serial_setting import Ui_Dialog
from PyQt5.QtWidgets import QDialog
import serial.tools.list_ports
class SerialSettingDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.init_ui()
        self.baud=None
        self.data_bit=None
        self.stop_bit=None

    def init_ui(self):
        self.setWindowTitle("串口设置")
        self.setFixedSize(400, 300)
    def accept(self):
        super().accept() # 调用父类的 accept 方法关闭对话框
        # 结束后读取设置
        self.acceptbaud = self.ui.cb_baud.currentText()
        self.data_bit = self.ui.cb_data.currentText()
        self.stop_bit = self.ui.cb_stop.currentText()
        


if __name__ == "__main__":
    import sys
    from PyQt5.QtWidgets import QApplication
    app = QApplication(sys.argv)
    dialog = SerialSettingDialog()
    dialog.show()
    sys.exit(app.exec_())